package com.tian.system.controller;

import java.util.List;

import com.tian.common.core.controller.BaseController;
import com.tian.common.core.domain.AjaxResult;
import com.tian.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tian.system.domain.Menu;
import com.tian.system.service.IMenuService;


/**
 * 菜单表 信息操作处理
 *
 * @author zcx
 * @date 2019-12-09 15:27:41
 */
@Controller
@RequestMapping("/system/menu")
public class MenuController extends BaseController {
    private String prefix = "system/menu";

    @Autowired
    private IMenuService menuService;

    /**
     * 查询菜单表列表
     */
    @PostMapping("/page")
    @ResponseBody
    public TableDataInfo page(Menu menu) {
        startPage();
        List<Menu> list = menuService.selectMenuList(menu);
        return getDataTable(list);
    }

    /**
     * 查询菜单表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public String list(Menu menu) {
        List<Menu> list = menuService.selectMenuList(menu);
        return toAjax(list);
    }

    /**
     * 新增保存菜单表
     */
    @PostMapping("/add")
    @ResponseBody
    public String addSave(Menu menu) {
        return toAjax(menuService.insertMenu(menu));
    }

    /**
     * 修改保存菜单表
     */
    @PostMapping("/edit")
    @ResponseBody
    public String editSave(Menu menu) {
        return toAjax(menuService.updateMenu(menu));
    }

    /**
     * 删除菜单表
     */
    @PostMapping("/remove")
    @ResponseBody
    public String remove(String id) {
        return toAjax(menuService.deleteMenuById(id));
    }

}
